import { createRouter, createWebHistory } from 'vue-router'
import toDoList from '@/views/ToDoList.vue'
import PaoMaDeng from '@/views/paoMaDeng.vue'
import attributeCalculations from '@/views/attributeCalculations.vue'
import getTheElement from '@/views/getTheElement.vue'
import ToRefs from '@/views/toRefs.vue'
import indexPage from '@/views/indexPage.vue'
import index2Page from '@/views/index2Page.vue'
import combinedPage from '@/views/combinedPage.vue'
import PageA from '@/views/PageA.vue'
import PageB from '@/views/PageB.vue'
import sonCom from '@/components/sonCom.vue'
import grandsonCom from '@/components/grandsonCom.vue'
import isPage from '@/views/isPage.vue'
import PiniaPractice from '@/views/piniaPractice.vue'
import PiniaPractice2 from '@/views/piniaPractice2.vue'
import FatherPage from '@/views/fatherPage.vue'
import SonSonPage from '@/views/SonSonPage.vue'
import keepAlive from '@/views/KeepAlive.vue'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [

    {
      path: '/list',
      component: toDoList
    },
    {
      path: '/index',
      component: indexPage
    },
    {
      path: '/index2',
      component: index2Page
    },
    {
      path: '/pao',
      component: PaoMaDeng
    },
    {
      path: '/attr',
      component: attributeCalculations
    },
    {
      path: '/getEle',
      component: getTheElement
    },
    {
      path: '/toRefs',
      component: ToRefs
    },
    {
      path: '/com',
      component: combinedPage
    },
    {
      path: '/son',
      component: sonCom
    },
    {
      path: '/grand',
      component: grandsonCom
    },
    //   Vue3的路由跳转的两个路由
    {
      path: '/PageA',
      component: PageA
    },
    {
      // path: '/PageB',
      path: '/PageB/:id',
      // 只要使用 name 和 params 进行跳转传参的时候需要修改路由 定义name的时候不需要携带 /
      name: 'PageB',
      component: PageB
    },
    {
      path: '/is',
      component: isPage
    },
    // 学习pinia使用的两个组件
    {
      path: '/pinia',
      component: PiniaPractice
    },
    {
      path: '/pinia2',
      component: PiniaPractice2
    },
    // 父子组件传参
    {
      path: '/father',
      component: FatherPage
    },
    {
      path: '/son2',
      component: SonSonPage
    },
    {
      path: '/keep',
      component: keepAlive
    }


  ]
})

export default router
